package com.li.onjava8.concurrent.es.task;

import com.li.onjava8.concurrent.utils.Nap;

import java.util.concurrent.atomic.AtomicBoolean;

/**
 * @author li
 * @date 2023/10/30 14:54
 */
public class QuittableTask implements Runnable{
    final int id;

    public QuittableTask(int id) {
        this.id = id;
    }

    AtomicBoolean running = new AtomicBoolean();

    public void quit() {
        running.set(false);
    }


    @Override
    public void run() {
        while (running.get())
            new Nap(0.1);
        System.out.println(id + " ");
    }
}
